package com.yuan.javaT和V的用法复习;

import lombok.Data;

/*
 *  @author 雨安
 *  类名： TDemo1
 *  创建时间：2024/5/6
 */
public class TDemo1<T> {
    private T data;

    private String msg;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "TDemo1{" +
                "data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }

    public static void main(String[] args) {
        //创建对象
        TDemo1<Integer> tDemo1 = new TDemo1<>();
        //设置值 泛型则会锁定配置为指定泛型
        tDemo1.setData(10);
        //打印
        System.out.println("Integer Data:" + tDemo1.getData());

        //创建对象
        TDemo1<String> tDemo2 = new TDemo1<>();
        //设置值 泛型则会锁定配置为指定泛型
        tDemo2.setData("Hello World。");
        //打印
        System.out.println("Integer Data:" + tDemo2.getData());


    }


}



